﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Optimization;
using System.Web.Routing;

namespace PaidTimeOffMVCUI
{
    public class MvcApplication : System.Web.HttpApplication
    {
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);
        }

        protected void Application_Error(Object sender, EventArgs e)
        {
            //记录事件日志
            Exception error = Server.GetLastError().GetBaseException();

            if(!EventLog.SourceExists("PaidTimeOff"))
            {
                EventLog.CreateEventSource("PaidTimeOff", "Application");
            }

            EventLog eventlog = new EventLog();
            eventlog.Log = "Application";
            eventlog.Source = "PaidTimeOff";
            eventlog.WriteEntry(error.ToString(), EventLogEntryType.Error);

            //设置错误提醒邮件
        }
    }
}
